package com.lzh.others;

import java.io.*;

/**
 * @Description:
 * @Author: LiuZiHao
 * @Date: 2022/7/22 10:02
 */
public class SerializableDome {
    public static void main(String[] args) throws Exception, IOException {
        // 序列化存储
        ObjectOutputStream owt = new ObjectOutputStream(new FileOutputStream("D:\\测试\\05.dat"));
        User user = new User("蒙奇.D.路飞", "123456", "路飞");
        owt.writeObject(user);
        owt.flush();
        owt.close();
        // 反序列化输出
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream("D:\\测试\\05.dat"));
        User user1 = (User) ois.readObject();// 反序列化
        System.out.println(user1);
        System.out.println(user1.getPassWord());
        ois.close();

    }

}
